package cn.wangyu.msblogadmin.admin.service.impl;

import cn.wangyu.msblogadmin.admin.dto.AdminDto;
import cn.wangyu.msblogadmin.admin.entity.SysAdmin;
import cn.wangyu.msblogadmin.admin.mapper.SysAdminMapper;
import cn.wangyu.msblogadmin.admin.service.ISysAdminService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 管理员表 服务实现类
 * </p>
 *
 * @author wangyu
 * @since 2021-09-04
 */
@Service
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class SysAdminServiceImpl extends ServiceImpl<SysAdminMapper, SysAdmin> implements ISysAdminService {

    private final SysAdminMapper sysAdminMapper;


    @Override
    public SysAdmin getByUsername(String username) {
        return sysAdminMapper.getByUsername(username);
    }

    @Override
    public IPage<SysAdmin> findPages(AdminDto adminDto) {
        Page<SysAdmin> page = new Page<>();
        page.setSize(adminDto.getPageSize());
        page.setCurrent(adminDto.getCurrentPage());
        List<SysAdmin> list = sysAdminMapper.findPages(adminDto);
        return page.setRecords(list);
    }
}
